:: @echo off
setlocal enabledelayedexpansion

for /f %%a in ('powershell -NoLogo -NoProfile -Command "Get-Date -Format yyyyMMdd"') do set TODAY=%%a


set DIR=D:\study\SourceParent\bat

set FILE=%DIR%\%TODAY%.flag


if not exist "%FILE%" (

(
	chcp 65001 >nul
    echo ===== %date% %time% =====
	
	for %%i in ("D:\study\SourceParent" 
				"%USERPROFILE%\AppData\Roaming\JetBrains\IntelliJIdea2025.1\workspace") do (
		cd /d %%i
		git fetch --all
		git reset --hard origin/master
	)

) >> %DIR%\auto-git.log 2>&1
cd /d %DIR%
del *.flag
echo [%date% %time%] pulled > "%FILE%"

)else (
echo [%date% %time%] pull canceled >> %DIR%\auto-git.log
)

endlocal